package com.woniuxy.couponassembly.dao;

import com.woniuxy.couponassembly.model.Coupon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Liyfi
 * @since 2021-05-31
 */
public interface CouponMapper extends BaseMapper<Coupon> {

    @Insert("insert into coupon (coupon_name,coupon_way,coupon_type,satisfy,reduce,discount,Issued_quantity,remark,user_type,limit_num,term_of_validity,start_date,end_date,need_credit) value(#{couponName},#{couponWay},#{couponType},#{satisfy},#{reduce},#{discount},#{issuedQuantity},#{remark},#{userType},#{limitNum},#{termOfValidity},#{startDate},#{endDate},#{needCredit})")
    int addCoupon(Coupon coupon);

    @Select("select limit_num from coupon where coupon_id = #{couponId}")
    int getLimitNum(int couponId);

    @Select("select Issued_quantity from coupon where coupon_id = #{couponId}")
    int getIssuedQuantity(int couponId);

    @Select("select * from coupon where coupon_id = #{couponId}")
    Coupon findCoupon(int couponId);
}
